/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UI;

/**
 *
 * @author manik
 */
public class TypeEditor extends javax.swing.JPanel {

    /**
     * Creates new form TypeEditor
     */
    public TypeEditor() {
        initComponents();
    }
    
    public TypeEditor(UI.NodeData node_data, MainWindow window_obj) {
        initComponents();
        
        valueButtonGroup.add(magicRadioButton);
        valueButtonGroup.add(enumerationRadioButton);
        
        this.node_data = node_data;
        this.window_obj = window_obj;
        
        
        launch();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        valueButtonGroup = new javax.swing.ButtonGroup();
        nameLabel = new javax.swing.JLabel();
        adTextBox = new javax.swing.JTextField();
        arrayDimensionLabel = new javax.swing.JLabel();
        nameTextBox = new javax.swing.JTextField();
        lengthLabel = new javax.swing.JLabel();
        lengthTextBox = new javax.swing.JTextField();
        ValueLabel = new javax.swing.JLabel();
        magicRadioButton = new javax.swing.JRadioButton();
        enumerationRadioButton = new javax.swing.JRadioButton();
        magicValueTextBox = new javax.swing.JTextField();
        enumerationComboBox = new javax.swing.JComboBox();
        enumerationValueComboBox = new javax.swing.JComboBox();
        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        enumerationModuleComboBox = new javax.swing.JComboBox();

        setName("Type Editor");

        nameLabel.setText("Name");

        adTextBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adTextBoxActionPerformed(evt);
            }
        });

        arrayDimensionLabel.setText("Array dimension");

        lengthLabel.setText("Length (bits)");

        lengthTextBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lengthTextBoxActionPerformed(evt);
            }
        });

        ValueLabel.setText("Value");

        magicRadioButton.setText("Magic number");
        magicRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                magicRadioButtonStateChanged(evt);
            }
        });
        magicRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                magicRadioButtonActionPerformed(evt);
            }
        });

        enumerationRadioButton.setText("Enumeration");
        enumerationRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enumerationRadioButtonActionPerformed(evt);
            }
        });

        enumerationComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        enumerationComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enumerationComboBoxActionPerformed(evt);
            }
        });

        enumerationValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        okButton.setText("Ok");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        enumerationModuleComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        enumerationModuleComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enumerationModuleComboBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(magicRadioButton)
                            .addComponent(enumerationRadioButton))
                        .addGap(41, 41, 41)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(magicValueTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(enumerationModuleComboBox, 0, 138, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(enumerationComboBox, 0, 138, Short.MAX_VALUE)
                                .addGap(22, 22, 22)
                                .addComponent(enumerationValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(arrayDimensionLabel)
                                .addGap(27, 27, 27))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(nameLabel)
                                .addGap(77, 77, 77))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lengthLabel)
                                .addGap(43, 43, 43)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lengthTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(nameTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(adTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(ValueLabel)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(cancelButton)
                        .addGap(18, 18, 18)
                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameLabel)
                    .addComponent(nameTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(arrayDimensionLabel)
                    .addComponent(adTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lengthLabel)
                    .addComponent(lengthTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(ValueLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(magicRadioButton)
                    .addComponent(magicValueTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(enumerationRadioButton)
                    .addComponent(enumerationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(enumerationValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(enumerationModuleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton)
                    .addComponent(okButton))
                .addGap(30, 30, 30))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void adTextBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adTextBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_adTextBoxActionPerformed

    private void lengthTextBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lengthTextBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_lengthTextBoxActionPerformed

    private void magicRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_magicRadioButtonStateChanged
        // TODO add your handling code here:
        
    }//GEN-LAST:event_magicRadioButtonStateChanged

    private void magicRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_magicRadioButtonActionPerformed
        // TODO add your handling code here:
        
        //if (magicRadioButton.isSelected()) {
            magicValueTextBox.setEnabled(true);
            enumerationComboBox.setEnabled(false);
            enumerationValueComboBox.setEnabled(false);
            enumerationModuleComboBox.setEnabled(false);
            lengthTextBox.setEnabled(true);
        //}
    }//GEN-LAST:event_magicRadioButtonActionPerformed

    private void enumerationRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enumerationRadioButtonActionPerformed
        // TODO add your handling code here:
        //if (enumerationRadioButton.isSelected()) {
            magicValueTextBox.setEnabled(false);
            enumerationComboBox.setEnabled(true);
            enumerationValueComboBox.setEnabled(true);
            enumerationModuleComboBox.setEnabled(true);
            lengthTextBox.setEnabled(false);
            loadEnumerations();
        //}
    }//GEN-LAST:event_enumerationRadioButtonActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
                
        DataLogic.TypeInfo type_obj = node_data.get_type_info();
        // Validate name
        if (nameTextBox.getText().isEmpty()) {
            return;
        }
        
        switch(type_obj.get_type()) {
            
            case DATA_TYPE:
            
            // For super-types (types containing sub-types), only name needs to
            // be validated.
            if (node_data.get_container_node().isLeaf() == false) {
                type_obj.set_name(nameTextBox.getText());
                containerFrame.dispose();
                return;
            }                
                
            // Check num_elems field
            try {
                Long.parseLong(adTextBox.getText());
            } catch(NumberFormatException e) {
                return;
            }
            
            if (node_data.get_container_node().getLevel() == 3) {
                // No more validations required for sub-type
                DataLogic.SchemaInfo schema_info = (DataLogic.SchemaInfo)type_obj;
                node_data.set_field_name(nameTextBox.getText());
                node_data.set_elements(Long.parseLong(adTextBox.getText()));
                containerFrame.dispose();
                return;
            }
            
            // Validate value
            if (magicRadioButton.isSelected()) {
                
                // magic value validation
                try {
                    Long.parseLong(magicValueTextBox.getText());
                } catch(NumberFormatException e) {
                    return;
                }
                
                // length field enumeration
                try {
                    Long.parseLong(lengthTextBox.getText());
                } catch (NumberFormatException e) {
                    return;
                }
                
                // Apply
                type_obj.set_name(nameTextBox.getText());
                
                DataLogic.SchemaInfo schema_info = (DataLogic.SchemaInfo)type_obj;
                Number value = Long.parseLong(magicValueTextBox.getText());
                Number length = Long.parseLong(lengthTextBox.getText());
                Number num_elems = Long.parseLong(adTextBox.getText());
                schema_info.set_schema_magic_value(value, length);
                node_data.set_elements(num_elems);
                
                containerFrame.dispose();
                
            } else {
        
                // enumerations validation
                if (enumerationModuleComboBox.getSelectedItem() == null) {
                    return;
                }
                
                if (enumerationComboBox.getSelectedItem() == null) {
                    return;
                }
                
                if (enumerationValueComboBox.getSelectedItem() == null) {
                    return;
                }
                
                // Now perform actions
                type_obj.set_name(nameTextBox.getText());
                
                DataLogic.SchemaInfo schema_info = (DataLogic.SchemaInfo)type_obj;
                String enum_module = enumerationModuleComboBox.getSelectedItem().toString();
                String enum_name = enumerationComboBox.getSelectedItem().toString();
                String enum_value = enumerationValueComboBox.getSelectedItem().toString();
                Number num_elems = Long.parseLong(adTextBox.getText());
                schema_info.set_schema_enumeration(enum_module, enum_name, enum_value);
                node_data.set_elements(num_elems);
                
                // @todo: Add handling for closing the window
                containerFrame.dispose();
                
            }
            
            case ENUM_MODULE:
            case SCHEMA_MODULE:
            case ENUM_DEFINITION:
                type_obj.set_name(nameTextBox.getText());
                containerFrame.dispose();
                break;
                
            case ENUM_VALUE:
                
                // validate value
                try {
                    Number enum_value = Long.parseLong(magicValueTextBox.getText());
                    DataLogic.EnumsInfo enum_info = (DataLogic.EnumsInfo)type_obj;
                    
                    enum_info.set_value(enum_value);
                    type_obj.set_name(nameTextBox.getText());
                    containerFrame.dispose();
                } catch (NumberFormatException e) {
                    return;
                }
                
            default:
                break;
        }
    }//GEN-LAST:event_okButtonActionPerformed

    private void enumerationComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enumerationComboBoxActionPerformed
        // TODO add your handling code here:
        javax.swing.tree.DefaultMutableTreeNode enum_val_node;
        javax.swing.tree.DefaultMutableTreeNode enum_node;
        UI.NodeData enums_node_data = (UI.NodeData)enumerationComboBox.getSelectedItem();
        enumerationValueComboBox.removeAllItems();
        if (enums_node_data == null) {
            return;
        }
        enum_node = enums_node_data.get_container_node();
        
        if (enum_node.isLeaf()) {
            enum_val_node = null;
        } else {
            enum_val_node = (javax.swing.tree.DefaultMutableTreeNode)enum_node.getFirstChild();
        }
        
        while (enum_val_node != null) {
            //DataLogic.EnumsInfo enum_val_info = (DataLogic.EnumsInfo)((UI.NodeData)enum_val_node.getUserObject()).get_type_info();
            UI.NodeData enum_val_node_data = (UI.NodeData)enum_val_node.getUserObject();
            enumerationValueComboBox.addItem(enum_val_node_data);
            enum_val_node = (javax.swing.tree.DefaultMutableTreeNode)enum_val_node.getNextSibling();
        }
    }//GEN-LAST:event_enumerationComboBoxActionPerformed

    private void enumerationModuleComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enumerationModuleComboBoxActionPerformed
        // TODO add your handling code here:
        
        javax.swing.tree.DefaultMutableTreeNode enum_node;
        javax.swing.tree.DefaultMutableTreeNode module_node;
        UI.NodeData module_node_data = (UI.NodeData)enumerationModuleComboBox.getSelectedItem();
        enumerationComboBox.removeAllItems();
        if (module_node_data == null) {
            return;
        }
        module_node = module_node_data.get_container_node();        
        
        if (module_node.isLeaf()) {
            enum_node = null;
        } else { 
            enum_node = (javax.swing.tree.DefaultMutableTreeNode)module_node.getFirstChild();
        }
        while (enum_node != null) {
            UI.NodeData enumNodeData = (UI.NodeData)enum_node.getUserObject();
            enumerationComboBox.addItem(enumNodeData);
            enum_node = (javax.swing.tree.DefaultMutableTreeNode)enum_node.getNextSibling();
        }
        
    }//GEN-LAST:event_enumerationModuleComboBoxActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        // TODO add your handling code here:
        containerFrame.dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ValueLabel;
    private javax.swing.JTextField adTextBox;
    private javax.swing.JLabel arrayDimensionLabel;
    private javax.swing.JButton cancelButton;
    private javax.swing.JComboBox enumerationComboBox;
    private javax.swing.JComboBox enumerationModuleComboBox;
    private javax.swing.JRadioButton enumerationRadioButton;
    private javax.swing.JComboBox enumerationValueComboBox;
    private javax.swing.JLabel lengthLabel;
    private javax.swing.JTextField lengthTextBox;
    private javax.swing.JRadioButton magicRadioButton;
    private javax.swing.JTextField magicValueTextBox;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JTextField nameTextBox;
    private javax.swing.JButton okButton;
    private javax.swing.ButtonGroup valueButtonGroup;
    // End of variables declaration//GEN-END:variables

    //User defined members
    private UI.NodeData node_data;
    private MainWindow window_obj;
    private javax.swing.JFrame containerFrame;
    
    
    //User defined methods
    public void setContainer(javax.swing.JFrame jframe) {
        containerFrame = jframe;
    }
    private void clear_editor() {
        nameTextBox.setText("");
        lengthTextBox.setEnabled(false);
        lengthTextBox.setText("");
        adTextBox.setText("");
        adTextBox.setEnabled(false);
        magicValueTextBox.setText("");
        magicValueTextBox.setEnabled(false);
        
 
        enumerationRadioButton.setSelected(false);
        magicRadioButton.setSelected(false);
        enumerationRadioButton.setEnabled(false);
        magicRadioButton.setEnabled(false);
        
        enumerationComboBox.removeAllItems();
        enumerationComboBox.setEnabled(false);
        
        enumerationValueComboBox.removeAllItems();
        enumerationValueComboBox.setEnabled(false);
        
        enumerationModuleComboBox.removeAllItems();
        enumerationModuleComboBox.setEnabled(false);
        
    }
    
    public javax.swing.JButton getOkButton() {
        return okButton;
    }
    public final void launch() {
        
        DataLogic.TypeInfo obj_type =(DataLogic.TypeInfo)node_data.get_type_info();
        clear_editor();
        nameTextBox.setText(obj_type.get_name());
        nameTextBox.select(0, 1000);    // select all text in the text box
        
        if (obj_type.get_type() != DataLogic.TypeEnums.DATA_TYPE) {
            
            if (obj_type.get_type() == DataLogic.TypeEnums.ENUM_VALUE) {
                DataLogic.EnumsInfo enum_info = (DataLogic.EnumsInfo)obj_type;
                magicValueTextBox.setEnabled(true);
                magicValueTextBox.setText(enum_info.get_value().toString());
                magicRadioButton.setSelected(true);
            }
        } else {
            
            //For super-type nodes, only name is configurable
            if (node_data.get_container_node().isLeaf() == false) {
                return;
            }
            
            DataLogic.SchemaInfo schema_info = (DataLogic.SchemaInfo)obj_type;
            
            // Array
            if (node_data.get_container_node().getLevel() == 3) {
              // Array elements allowed only for sub-types
              adTextBox.setEnabled(true);
              adTextBox.setText(node_data.get_elements().toString());
              
              if (schema_info.is_value_magic() == true) {
                  return;       // No more options
              }
              
            } else {
                adTextBox.setText("1");
            }
            
            //Value
            magicRadioButton.setEnabled(true);
            enumerationRadioButton.setEnabled(true);
            if (schema_info.is_value_magic() == true) {
                magicRadioButton.setSelected(true);
                magicValueTextBox.setEnabled(true);
                magicValueTextBox.setText(schema_info.get_value().toString());
                enumerationComboBox.setEnabled(false);
                enumerationValueComboBox.setEnabled(false);
                enumerationModuleComboBox.setEnabled(false);
                lengthTextBox.setEnabled(true);
                
                // Length
                lengthTextBox.setEnabled(true);
                lengthTextBox.setText(schema_info.get_length().toString());
                
                // Value
                magicValueTextBox.setText(schema_info.get_value().toString());
                
            } else {
                // Data type uses enumeration
                enumerationRadioButton.setSelected(true);
                magicValueTextBox.setEnabled(false);
                enumerationComboBox.setEnabled(true);
                enumerationValueComboBox.setEnabled(true);
                enumerationModuleComboBox.setEnabled(true);
                lengthTextBox.setEnabled(false);
                
                loadEnumerations();
                
                // Set specific values
                //@todo: Load specific enum values already present in enum
            }
        }
    }
    
    public void loadEnumerations() {
        java.util.ArrayList list = window_obj.get_enum_definitions();
        enumerationComboBox.removeAll();
        enumerationModuleComboBox.removeAll();
        enumerationValueComboBox.removeAll();
        
        while (list.isEmpty() == false) {
            javax.swing.tree.DefaultMutableTreeNode module_node = (javax.swing.tree.DefaultMutableTreeNode)list.remove(0);
            //DataLogic.ModuleInfo module_info = (DataLogic.ModuleInfo)((UI.NodeData)module_node.getUserObject()).get_type_info();
            UI.NodeData nodeData = (UI.NodeData)module_node.getUserObject();
            enumerationModuleComboBox.addItem(nodeData);
            
            if (nodeData.toString().equals(node_data.toString())) {
                enumerationModuleComboBox.setSelectedItem(nodeData);
            }
        }
    }

}
